package com.dzm.xgb.core.controller.admin;

import com.dzm.common.result.R;
import com.dzm.xgb.core.pojo.entity.Lend;
import com.dzm.xgb.core.pojo.entity.LendItem;
import com.dzm.xgb.core.service.LendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 作者：Dzm
 * 时间：2024-09-25-10:55
 * 功能：
 */

@RestController
@RequestMapping("/admin/core/lend")
public class AdminLendController {

    @Autowired
    private LendService lendService;

    @GetMapping("/list")
    public R list() {
        List<Lend> list = lendService.getList();

        return R.ok().data("list", list);
    }

    @GetMapping("/show/{id}")
    public R show(@PathVariable("id")Long id){
        Map<String, Object> map = lendService.show(id);

        return R.ok().data("lendDetail", map);
    }

    @GetMapping("makeLoan/{id}")
    public R makeLoan(@PathVariable("id") Long id) {
        lendService.makeLoan(id);

        return R.ok().message("放款成功！");
    }

}
